package com.wx.cloud.security.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class User  implements UserDetails {
    private Integer id;
    private String name;
    private String password;
    private String code;
    private String sessionCode;
    private String typeCode;
    private String sex;
    private Integer age;
    private String education;
    private String university;
    private String naative;
    private String address;
    private String phone;
    private String otherphone;
    private String groupCode;
    private String typeName;
    private Integer pageSize;
    private Integer pageNum;
    private String jurisdictionCode;
    private String jurisdictionName;
    private String timeAdmission;
    private String frequency;
    private String classroom;
    private String position;
    private String frontGroupCode;
    private String adjustmentGroupDate;
    private Integer missNumber;
    private Date missTime;
    private Date allowTime;
    private Integer status;
    private Set<? extends GrantedAuthority>  authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return name;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        if(this.status==null){
            return false;
        }
        return this.status==1;
    }
}

